package com.assisjrs.jpaandroid.persistence;

import java.util.Map;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class PersistenceProviderImpl implements PersistenceProvider {
	@Override
	public EntityManagerFactory createEntityManagerFactory(final String persistenceUnitName, final Map properties) {
		final SQLiteOpenHelper openHelper = new OpenHelper((Context) properties.get("context"));//npe.

		final SQLiteDatabase sqLiteDatabase = openHelper.getWritableDatabase();

		return new EntityManagerFactoryImpl(sqLiteDatabase, persistenceUnitName, properties);
	}
}
